import request from '@/utils/request.js'
// import { defHttp } from '@/utils/axios';
import {useTokenStore} from '@/stores/token'
import axios from 'axios'
// const useToken=useTokenStore()
const baseURL='http://8.130.42.115:8000'
export const studentLoginService = (loginData) => {
    const params = new URLSearchParams()
    for (let key in loginData) {
        params.append(key, loginData[key]);
    }
    const data ={
        "studentID":loginData.username,
        "password":loginData.password
    }
    // return {
    //     "code": 1,
    //     "msg": "success",
    //     "data": "eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoi6YeR5bq4IiwiaWQiOjEsInVzZXJuYW1lIjoiamlueW9uZyIsImV4cCI6MTY2MjIwNzA0OH0.KkUc_CXJZJ8Dd063eImx4H9Ojfrr6XMJ-yVzaWCVZCo"
    // };
    return request.post('/student/login',data,{headers: {
        "Content-Type":"application/json"
      },});
    //return request.post('/user/register',params);
}

export const teacherLoginService = (loginData) => {
    const params = new URLSearchParams()
    for (let key in loginData) {
        params.append(key, loginData[key]);
    }
    const data ={
        "teacherID":loginData.username,
        "password":loginData.password
    }
    // return {
    //     "code": 200,
    //     "msg": "success",
    //     "data": "eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoi6YeR5bq4IiwiaWQiOjEsInVzZXJuYW1lIjoiamlueW9uZyIsImV4cCI6MTY2MjIwNzA0OH0.KkUc_CXJZJ8Dd063eImx4H9Ojfrr6XMJ-yVzaWCVZCo"
    // };
    return request.post('/teacher/login',data,{headers: {
        "Content-Type":"application/json"
      },});
}

export const adminLoginService = (loginData) => {
    const data ={
        "adminID":loginData.username,
        "password":loginData.password
    }
    // return {
    //     "code": 1,
    //     "msg": "success",
    //     "data": "eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoi6YeR5bq4IiwiaWQiOjEsInVzZXJuYW1lIjoiamlueW9uZyIsImV4cCI6MTY2MjIwNzA0OH0.KkUc_CXJZJ8Dd063eImx4H9Ojfrr6XMJ-yVzaWCVZCo"
    // };
    //console.log(111)
    return request.post('/admin/login',data,{headers: {
        "Content-Type":"application/json"
      },});
}

export const testService = (loginData) => {
    const params = new URLSearchParams()
    for (let key in loginData) {
        params.append(key, loginData[key]);
    }
    // return {
    //     "code": 1,
    //     "msg": "success",
    //     "data": "eyJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoi6YeR5bq4IiwiaWQiOjEsInVzZXJuYW1lIjoiamlueW9uZyIsImV4cCI6MTY2MjIwNzA0OH0.KkUc_CXJZJ8Dd063eImx4H9Ojfrr6XMJ-yVzaWCVZCo"
    // };
    console.log(111)
    return request.get('/depts');
}
